package shujvjiegou.week6;

import java.util.Scanner;
import java.util.Stack;

public class stack_do {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Stack<Integer> stack = new Stack<>();
        int flag = 0;
        while (flag != -1) {
            flag = scan.nextInt();
            try {
                if (flag == 1) {
                    stack.push(scan.nextInt());
                } else if (flag == 0) {
                    System.out.print(stack.pop() + " ");
                }
            } catch (Exception e) {
                System.out.print("error ");
            }

        }
    }
}
